Expand description
§Overview
Motore is a library of the basic abstractions of middlewares for building robust networking clients and servers.
Motore is greatly inspired by the tower
crate, and we have used / modified
some of Tower
’s code and documentation. We really appreciate the work that
the Tower
team have done.
Tower
is licensed under the MIT license, and a copy can be found under
the licenses/tower
directory.
Motore provides a simple core abstraction, the Service
trait, which
represents an asynchronous function taking a request and returning either a
response or an error. This abstraction can be used to model both clients and
servers.
Generic components, like timeouts
, rate limiting
, and load balancing
,
can be modeled as Service
s that wrap some inner service and apply
additional behavior before or after the inner service is called. This allows
implementing these components in a protocol-agnostic, composable way. Typically,
such services are referred to as middleware.
An additional abstraction, the Layer
trait, is used to compose
middleware with Service
s. If a Service
can be thought of as an
asynchronous function from a request type to a response type, a Layer
is
a function taking a Service
of one type and returning a Service
of a
different type. The ServiceBuilder
type is used to add middleware to a
service by composing it with multiple Layer
s.
Re-exports§
pub use service::BoxCloneService;
pub use service::Service;
pub use service::ServiceExt;
pub use service::UnaryService;
Modules§
- Builder types to compose layers and services
- Layer traits and extensions.
- Pre-defined Service traits that may be useful for specified use cases.
- Definition of the core
Service
trait to Motore. - Applies a timeout to request if the inner service’s call does not complete within specified timeout, the response will be aborted.
Type Aliases§
- Alias for a type-erased error type.
Attribute Macros§
- This macro can help you to write a
Service
in a more efficient way.